import QtQuick 2.9
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.5


Window {
    id: main
    visible: true
    width: 800
    height: 600
    color: "#CCCCCC"

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.LeftButton | Qt.RightButton
        onClicked: {
            if (mouse.button === Qt.RightButton)
                menu.popup()
        }
        onPressAndHold: {
            if (mouse.source === Qt.MouseEventNotSynthesized)
                menu.popup()
        }

        Menu {
             id: menu

             Action { text: qsTr("Tool Bar"); checkable: true }
             Action { text: qsTr("Side Bar"); checkable: true; checked: true }
             Action { text: qsTr("Status Bar"); checkable: true; checked: true }
             Action { text: "test1"; }
             Action { text: "test1"; }
             Action { text: "test1" }
             Action { text: "test1" }
             MenuSeparator {
                 contentItem: Rectangle {
                     implicitWidth: 160
                     implicitHeight: 2
                     color: "gray"
                 }
             }

             Menu {
                 title: qsTr("Advanced")
                 MenuItem {
                     text: "test1"
                 }
                 MenuItem {
                     text: "test2"
                 }
             }

             topPadding: 10
             bottomPadding: 10
             leftPadding: 9
             rightPadding: 9

             delegate: MenuItem {
                 id: menuItem
                 implicitWidth: 200
                 implicitHeight: 22

                 arrow: Canvas {
                     x: parent.width - width
                     implicitWidth: 40
                     implicitHeight: 22
                     visible: menuItem.subMenu
                     onPaint: {
                         var ctx = getContext("2d")
                         ctx.fillStyle = "#404040"
                         ctx.moveTo(15, 15)
                         ctx.lineTo(width - 18, height / 2)
                         ctx.lineTo(15, height - 15)
                         ctx.closePath()
                         ctx.fill()
                     }
                 }

                 contentItem: Text {
                     leftPadding: menuItem.indicator.width
                     rightPadding: menuItem.arrow.width
                     text: menuItem.text
                     font: menuItem.font
                     color: "black"
                     horizontalAlignment: Text.AlignLeft
                     verticalAlignment: Text.AlignVCenter
                     elide: Text.ElideRight
                 }

                 background: Rectangle {
                     implicitWidth: 200
                     implicitHeight: 22
                     radius: 2
                     opacity: enabled ? 1 : 0.3
                     color: menuItem.highlighted ? "#90c8f6" : "transparent"
                 }
             }

             background: Rectangle {
                 color: "transparent"
                 id: aaa
                  implicitWidth: 200
                  implicitHeight: 22
                  border.color: "#00000000"
                  radius: 8
                  border.width: 1
                  Rectangle {
                      id: aasdf
                      anchors {
                          left: aaa.left
                          right: aaa.right
                          top: aaa.top
                          bottom: aaa.bottom
                          leftMargin: 8
                          rightMargin: 8
                          topMargin: 8
                          bottomMargin: 8
                      }
                      border.color: "#00000000"
                      radius: 4
                      border.width: 1
                      color: "white"


                  }
                  DropShadow {
                      anchors.fill: aasdf
                      horizontalOffset: 1
                      verticalOffset: 1
                      radius: 8
                      samples: 9
                      source: aasdf
                      color: "black"
                  }
             }

        }
    }


}
